#include "head.h"

int work(int net_fd){
    
    USER user;
    user.IS_LOGIN = 0;

    while(1){

        /*
        if(user.IS_LOGIN == 0){
            
            int choice;
            recv(net_fd,&choice,sizeof(int),MSG_WAITALL);
            if(choice == 1){
                //查询数据库该用户是否注册

                //未注册->
                //执行注册逻辑
                //接收用户名
                int name_len = 0;
                recv(net_fd,&name_len,sizeof(int),MSG_WAITALL);
                char name[20] = {0};
                recv(net_fd,name,name_len,MSG_WAITALL);
                //设置用户密码
                int ps_word_len = 0;
                recv(net_fd,&ps_word_len,sizeof(int),MSG_WAITALL);
                char password[60] = {0};
                recv(net_fd,password,ps_word_len,MSG_WAITALL);
                //将用户数据保存到卑职文件
                //...

                user.IS_LOGIN = 1;
                continue;

            }else if(choice == 2){
                //接收用户名
                //接收密码
                //验证密码
                //通过
            }
        }
        */


        printf("waiting command\n");
        fflush(stdout);

        char command[60] = {0};
        int comm_len = 0;
        int ret = recv(net_fd,&comm_len,sizeof(int),MSG_WAITALL);
        if(ret == 0){
            return 0;
        }
        recv(net_fd,command,comm_len,MSG_WAITALL);
        
        start_comm(net_fd,command);

    }
    
    return 0 ;

}



















